package operiation;

import javax.sql.DataSource;
import java.sql.Connection;
import java.sql.PreparedStatement;
import java.sql.SQLException;
import java.util.Scanner;

/**
 * Creater with IntelliJ IDEA.
 * Description:
 * User: 86152
 * Dae: 2022-07-18
 * Time: 21:22
 */
public class modify {
    public static int work(DataSource dataSource, Connection connection) throws SQLException {
        Scanner scanner=new Scanner(System.in);
        System.out.println("输入修改的同学的学号");
        int id = scanner.nextInt();
        System.out.println("输入修改后的姓名");
        String name = scanner.next();
        String sql = "update student set name='"+name+"' where id="+id;
        PreparedStatement statement = connection.prepareStatement(sql);

        int n=statement.executeUpdate();
        return n;
    }
}
